#include <Process\Processing.h>


//void Processor::processingBlock(DATA_TYPE * startFrame, LENGTH_TYPE frameSize){
//
//
//}

Processor::Processor(){
}

void Processor::SetChan( DataChannel *dataChan){
	//dataChannel.Length = dataChan.Length;
	//dataChannel.SampleRate = dataChan.SampleRate;
	//// Xoa du lieu hien tai neu co
	//if (dataChannel.RawData != NULL){
	//	delete[] dataChannel.RawData;
	//}
	//dataChannel.RawData = new DATA_TYPE[dataChan.Length];
	//memcpy(dataChannel.RawData, dataChan.RawData, dataChan.Length * sizeof(DATA_TYPE));
	dataChannel = dataChan;
}

void Processor::processing(){

	// loop through input file in chunks of blockSize
	for (LENGTH_TYPE blockStart = 0; blockStart < dataChannel->Length; blockStart += option.BlockSize)
	{
		LENGTH_TYPE numSamplesInBlock = option.BlockSize;// Su dung overlap nen nay la frame size that
		if (blockStart + option.BlockSize > dataChannel->Length)
			numSamplesInBlock = dataChannel->Length % option.BlockSize;
		if (numSamplesInBlock)
		{
			processingBlock(&dataChannel->RawData[blockStart], numSamplesInBlock);
		}
	}
}


void Processor::SetOption(Option opt){
	option = opt;
}